//
//  labelcell.m
//  掌上海印
//
//  Created by 陈德锋 on 16/4/18.
//  Copyright © 2016年 handsome. All rights reserved.
//

#import "labelcell.h"

@implementation labelcell

+ (instancetype)labelcellWithTableView:(UITableView *)tableView
{
    static NSString *ID = @"imagecell";
    labelcell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[labelcell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }
    return cell;
}

-(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor whiteColor];
        
        _label = [[UILabel alloc] init];
        [self.contentView addSubview: _label];
        
        _label1 = [[UILabel alloc] init];
        [self.contentView addSubview: _label1];
        _label1.hidden = YES;
        
        _icon = [[UIImageView alloc] init];
        [self.contentView addSubview:_icon];
        _icon.hidden = YES;
    }
    return self;
}
-(void) layoutSubviews{
    [super layoutSubviews];
    _label.frame = CGRectMake([[UIScreen mainScreen]bounds].size.width-140, 0, 110, 45);
    _label.textColor = [UIColor grayColor];
    _label.textAlignment = NSTextAlignmentRight;
    
    _label1.frame = CGRectMake([[UIScreen mainScreen]bounds].size.width-140, 0, 110, 45);
    _label1.textColor = [UIColor grayColor];
    _label1.textAlignment = NSTextAlignmentRight;
    
    
    CGFloat nslayout = [[UIScreen mainScreen]bounds].size.width-self.contentView.frame.size.height-22;
    [_icon setTranslatesAutoresizingMaskIntoConstraints:NO];
    
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_icon attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1 constant:1]];
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_icon attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1 constant:nslayout]];
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_icon attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1 constant:11]];
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_icon attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeHeight multiplier:0.5 constant:0]];
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_icon attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeHeight multiplier:0.5 constant:0]];
    
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
